<?php

//echo br(3); ###########################################################################################

	$TEMP->set_file(array('handle' => DIR_VIEW_STUDENTS . 'myCurriculum.html'));
	
	$semesterLinker = $DSC->getSemesterLinker($strCourseID, '', false);

	if (!empty($semesterLinker)) {
		$TEMP->set_block('handle',  'semester', 'semesterRow');
		$activeSubj  	= '';
		foreach($semesterLinker as $semesterLinkerField => $semesterLinkerValue) {
			
			$semDesc 	 = $semesterLinkerValue['sem_desc'];
			$semLinkerID = $semesterLinkerValue['sem_linker_idPK'];
			
			$studentSemesterActiveYear  = $DSC->getStudentSemesterActiveYear($logUserID, $strCourseID, $semLinkerID);

			$studentSemesterActiveYearYearFrom = $studentSemesterActiveYear['year_from'];
			$studentSemesterActiveYearYearTo   = $studentSemesterActiveYear['year_to'];
			
			$semNote	 = (!empty($semesterLinkerValue['note'])) ? '*NOTE: ' . $semesterLinkerValue['note'] : '';
			
			$subjectListing = '';
			
			$studentSubjectSemLinkerCurriculum  = $DSC->getStudentSubjectSemLinkerCurriculum($logUserID, $strCourseID, $semLinkerID);
			
			$subjectListingSemLinker = ( !empty($studentSubjectSemLinkerCurriculum) ) ? $studentSubjectSemLinkerCurriculum : $DSC->getSubjectListingSemLinker($semLinkerID, $activeYear);
			
			//$subjectListingSemLinker = $DSC->getSubjectListingSemLinker($semLinkerID, $activeYear);
			
			if( !empty($subjectListingSemLinker) ) {
				$totalHRSTotal 	= 0;
				$totalUnits 	= 0;
				foreach($subjectListingSemLinker as $subjectListingSemLinkerValue) {

					$subjID 		= $subjectListingSemLinkerValue['subj_idPK'];
					$total_units 	= $subjectListingSemLinkerValue['total_units'];
					$totalHRS 		= $subjectListingSemLinkerValue['total_hrs'];
					$subjDesc 		= $subjectListingSemLinkerValue['subj_desc'];
					$co_req			= $subjectListingSemLinkerValue['co_req'];
					$pre_req		= $subjectListingSemLinkerValue['pre_req'];
					
					$total_units_parenthesis = ($total_units < 0) ? '(' . abs($total_units) . ')' : $total_units;
					
					$coChar  = (!empty($co_req)) ? $DSC->getReqSubjectID($co_req) : 'None';
					
					$preChar = (!empty($pre_req)) ? $DSC->getReqSubjectID($pre_req) : 'None';
					
					$lastInsert = ($subjectListingSemLinkerValue['subj_idPK'] == $LASTID) ? 'active-light' : '';
					
					$studentSubjectGrades = $STUD->getStudentSubjectGrades($logUserID, $subjID, $strCourseID, $semLinkerID);
					
					$studSubjLInkerID 	  = $studentSubjectGrades['stud_subj_linker_idPK'];
					$studSubjGrade 	  	  = $studentSubjectGrades['grade'];
					$studSubjEquivalence  = $studentSubjectGrades['equivalence'];
				
					if (!empty($studSubjGrade)) {
						/*if ($studSubjGrade == 'INC' || $studSubjGrade == 'DRP') {
							$studSubjGradeValue = $studSubjGrade;
							$gradeConvert = ($studSubjGrade == 'INC') ? '<span class="font-red">INC</span>' : '<span class="font-red">DROP</span>';
						}
						else {
							$gradeIfPercent = $globalCon->getGradeIfPercent($studSubjGrade);
							$studSubjGradeValue = ( $gradeIfPercent === true ) ? '---' : $studSubjGrade.'%';
							$gradeConvert = $studSubjEquivalence;
						}*/
						$gradeConvertion 	= $STUD->gradeConvertion($studSubjGrade);
						$studSubjGradeValue = $studSubjGrade;
						$gradeConvert 		= $gradeConvertion['description'];
					}
					else {
						$gradeConvert = '&nbsp;';
						$studSubjGradeValue = '&nbsp;';
					}
				
					$activeSubj .= $studentSubjectGrades['subj_idFK'] . '-';
					
					$keyPressInput 	= ' onkeypress="return numberDate(event, false);" onfocus="viewSaveButton(\'' . $subjID . '\')"';
					
					$subjectListing .= '<tr align="center" class="hover-light">
											<td class="transfery-td-bot" align="left">' . $subjDesc . '</td>
											<td class="transfery-td-bot">' . $subjectListingSemLinkerValue['subj_code'] . '</td>
											<td class="transfery-td-bot" align="center">' . $studSubjGradeValue . '</td>
											<td class="transfery-td-bot" align="center">
												<div class="transfery-convertion" id="transfery_grades">' . $gradeConvert . '</div>
											</td>
										</tr>';
					if ($total_units > 0) {
						$totalUnits = $totalUnits + $total_units;
					}
					$totalHRSTotal = $totalHRSTotal + $totalHRS;
				}
			}
			
			$SY_YEAR = ($studentSemesterActiveYearYearFrom == $studentSemesterActiveYearYearTo) ? $studentSemesterActiveYearYearFrom : $studentSemesterActiveYearYearFrom .'-'.$studentSemesterActiveYearYearTo;
			
			$SY_Y = (!empty($SY_YEAR)) ? ' <span class="font-red">SY: ' . $SY_YEAR . '</span>' : '';
			
			$TEMP->set_var(array('sem_desc' 			=> '<div class="subj-year-semester-value">' . $semDesc . $SY_Y . '</div>',
								 'sem_linker_id' 		=> $semLinkerID,
								 'sem_note'				=> $semNote,
								 'subject_listing' 		=> $subjectListing));
			$TEMP->parse('semesterRow', 'semester', true);
		}
	}
	else {
		$TEMP->set_var(array('sem_desc' 			=> '',
							 'add_subject_button' 	=> '',
							 'sem_linker_id' 		=> '',
							 'subject_listing'		=> ''));
	}
	
	$TEMP->set_var(array('stud_sub_menu'	=> $studentDesignName,
						 'stud_active_sem'	=> $studActiveSemester,
						 'total_fees'		=> $feesListing,
						 'fully_paid'		=> $fullyPaid,
						 'total_amount'		=> 'Php ' . number_format($totalAmount,2),
						 'sem_desc'			=> $semDesc['sem_desc'],
						 'sem_code'			=> $semDesc['sem_code'],
						));
?>